package so.sao.code.service.domain.entity;

import lombok.Data;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Version;

/**
 * 二维码可用码段记录表
 *
 * @author cuijunhua
 */
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
public class LookupTable extends BaseEntity {

    /**
     *
     */
    private static final long serialVersionUID = -1841723001189058031L;

    /**
     * 码段开始序号
     */
    private Long seqnumStart = 0L;
    /**
     * 码段结束序号
     */
    private Long seqnumEnd = 0L;
    /**
     * 当前已使用的标签数量
     * <p>
     * 该码段可用的条件为 seqnumStart + currentCount + count(想要生成的数量) <= seqnumEnd
     */
    private Long currentCount = 0L;
    /**
     * 当前版本号，用于实现乐观锁
     */
    @Version
    private Integer version = 0;
    
}
